package com.hsp.demo_10.singletonpattern;

public class Demo_01 {
    public static void main(String[] args) {
        /*
        单例模式之饿汉式
         */

        AA instance = AA.getInstance();

        AA instance1 = AA.getInstance();

        System.out.println(instance == instance1);

    }
}

class AA{

    //2、在类的内部创建该类对象
    private static AA instance = new AA();

    //1、私有化构造器
    private AA(){}

    //3、向外暴露一个公共的方法，用于返回该类的对象
    public static AA getInstance(){
        return instance;
    }
}